﻿using System.Collections.Generic;
using System.Threading.Tasks;
using TabbedTemplate.Models;

namespace TabbedTemplate.Services
{
    public interface IQueryService
    {
        /// <summary>
        /// 数据库是否已经初始化。
        /// </summary>
        /// <returns></returns>
        bool Initialized();

        /// <summary>
        /// 初始化。
        /// </summary>
        /// <returns></returns>
        Task InitializeAsync();

        /// <summary>
        /// 检查用户是否搜索过这个内容。
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        Task<SearchItemToReturn> GetSearchItemByString(string content, string cityName);
        /// <summary>
        /// 新增一条缓存内容。
        /// </summary>
        /// <param name="content"></param>
        /// <param name="cityName"></param>
        /// <returns></returns>
        Task InsertSearchItem(string content, string cityName);
        /// <summary>
        /// 读取最新十条。
        /// </summary>
        /// <returns></returns>
        Task<IList<SearchItemCache>> GetTenItems();


        Task DeleteSearchItemById(int id);

        Task CloseAsync();

        Task ConnectionUpdateAsync(SearchItemCache searchItemCache);
        Task ConnectionInsertAsync(SearchItemCache searchItemCache);


    }

    public class SearchItemToReturn
    {
        public bool HasCache { get; set; }

        public SearchItemCache SearchItem { get; set; }
    }
}
